#include "../src/dbusClient.hpp"

wddDbusClient::wddDbusClient()
{
  sessionConn=sdbus::createSessionBusConnection();
  proxy=sdbus::createProxy(*sessionConn,"org.HBTY.WorkDataManager","/org/HBTY/WorkDataManager");
}

wddDbusClient::~wddDbusClient()
{

}

long wddDbusClient::CreateTask(std::string name)
{
  long returnVal;
  proxy->callMethod("CreateTask").onInterface(InterFaceName).withArguments(name).storeResultsTo(returnVal);
  return returnVal;
}

void wddDbusClient::DeleteTask(long task_id)
{
  proxy->callMethod("DeleteTask").onInterface(InterFaceName).withArguments(task_id);
}

std::vector<std::string> wddDbusClient::GetTaskNameList()
{
  std::vector<std::string> ret;
  proxy->callMethod("GetTaskNameList").onInterface(InterFaceName).storeResultsTo(ret);
  return ret;
}

std::vector<long> wddDbusClient::GetTaskIDList()
{
  std::vector<long> ret;
  proxy->callMethod("GetTaskIDList").onInterface(InterFaceName).storeResultsTo(ret);
  return ret;
}

std::vector<long> wddDbusClient::GetRecordID(long task_id)
{
  std::vector<long> ret;
  proxy->callMethod("GetRecordID").onInterface(InterFaceName).withArguments(task_id).storeResultsTo(ret);
  return ret;
}

std::tuple<long,long,std::string,bool,bool> wddDbusClient::GetRecordInf(long rec_id)
{
  std::tuple<long,long,std::string,bool,bool> ret;
  proxy->callMethod("GetRecordInf").onInterface(InterFaceName).withArguments(rec_id).storeResultsTo(ret);
  return ret;
}

long wddDbusClient::CreateRecord(long stu_id,long task_id)
{
  long ret;
  proxy->callMethod("CreateRecord").onInterface(InterFaceName).withArguments(stu_id,task_id).storeResultsTo(ret);
  return ret;
}

void wddDbusClient::LoadTaskInf()
{
  proxy->callMethod("LoadTaskInf").onInterface(InterFaceName);
}

void wddDbusClient::FinishRecord(long rec_id)
{
  proxy->callMethod("FinishRecord").onInterface(InterFaceName).withArguments(rec_id);
}

bool wddDbusClient::CheckStudentExists(long stu_id)
{
  bool ret;
  proxy->callMethod("CheckStudentExists").onInterface(InterFaceName).withArguments(stu_id).storeResultsTo(ret);
  return ret;
}

